package com.smarthealthring.mm.ui.fragment;

import android.content.Intent;
import android.support.v4.content.ContextCompat;

import com.jakewharton.rxbinding2.view.RxView;
import com.smarthealthring.mm.R;
import com.smarthealthring.mm.base.BaseFragment;
import com.smarthealthring.mm.base.IPresenter;
import com.smarthealthring.mm.ui.activity.CountDownActivity;
import com.smarthealthring.mm.utils.statusbar.StatusBarCompat;
import com.smarthealthring.mm.widgets.SingleItemView;

import butterknife.BindView;
import io.reactivex.functions.Consumer;

/**
 * Created by hewei26 on 2018/4/8.
 */

public class SportsFragment extends BaseFragment {
    @BindView(R.id.siv_run)
    SingleItemView mSivRun;
    @BindView(R.id.siv_runindoor)
    SingleItemView mSivRunIndoor;
    @BindView(R.id.siv_hike)
    SingleItemView mSivHike;
    @BindView(R.id.siv_ride)
    SingleItemView mSivRide;

    @Override
    protected int getLayoutId() {
        return R.layout.frag_sport;
    }

    @Override
    protected void initEventAndData() {
        StatusBarCompat.setStatusBarColor(mActivity, ContextCompat.getColor(mActivity,R.color.title_green));
        //骑行
        RxView.clicks(mSivRide)
                .subscribe(new Consumer<Object>() {
                    @Override
                    public void accept(Object o) throws Exception {

                    }
                });
        mSivRide.setRightImgClickListener(new SingleItemView.RightImgClickListener() {
            @Override
            public void onRightImgClick() {
                startActivity(new Intent(mContext, CountDownActivity.class));
            }
        });

        //健走
        RxView.clicks(mSivHike)
                .subscribe(new Consumer<Object>() {
                    @Override
                    public void accept(Object o) throws Exception {

                    }
                });
        mSivHike.setRightImgClickListener(new SingleItemView.RightImgClickListener() {
            @Override
            public void onRightImgClick() {
                startActivity(new Intent(mContext, CountDownActivity.class));
            }
        });

        //跑步
        RxView.clicks(mSivRun)
                .subscribe(new Consumer<Object>() {
                    @Override
                    public void accept(Object o) throws Exception {

                    }
                });
        mSivRun.setRightImgClickListener(new SingleItemView.RightImgClickListener() {
            @Override
            public void onRightImgClick() {
                startActivity(new Intent(mContext, CountDownActivity.class));
            }
        });

        //室内跑
        RxView.clicks(mSivRunIndoor)
                .subscribe(new Consumer<Object>() {
                    @Override
                    public void accept(Object o) throws Exception {

                    }
                });
        mSivRunIndoor.setRightImgClickListener(new SingleItemView.RightImgClickListener() {
            @Override
            public void onRightImgClick() {
                startActivity(new Intent(mContext, CountDownActivity.class));
            }
        });
    }

    @Override
    protected IPresenter createPresenter() {
        return null;
    }

    @Override
    protected boolean isLazyLoad() {
        return false;
    }

    public static SportsFragment getInstance() {
        return new SportsFragment();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (!hidden) {
            StatusBarCompat.setStatusBarColor(mActivity, ContextCompat.getColor(mActivity,R.color.title_green));
        }
    }
}
